-
Notifications
You must be signed in to change notification settings - Fork 200
Add locked_by and quit_by columns to live_results #13297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Ok, I think the logic is correct now |
|
|
||
| scope :not_empty, -> { where.not(best: 0) } | ||
|
|
||
| scope :without_quitters, -> { where(quit_by_id: nil).or(where.not(best: 0)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case do you need the second or(where.not(best: 0)) part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sidenote: .or(not_empty) should work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do still want to show quitters for previous rounds.
Currently when someone is quit from round 2 who advanced from round 1 I mark them as quit in round 2 and 1, but I still want to show them in round 1. There is a case to be made to only mark them as quit in round 1 as those results will already be locked so only flipping the advancing will be necessary?
| has_many :live_results_without_quitters, | ||
| -> { without_quitters.order(:global_pos) }, | ||
| class_name: "LiveResult" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it feels like this shouldn't be a separate relation. Why does some_round.live_results.without_quitters (ie, applying the without_quitters scope to the live_results relation) not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I use it in a scope one line down in the
has_many :live_competitors, through: :live_results_without_quitters, source: :registration
| init_round | ||
| return 0 if number == 1 || linked_round.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you ignoring the return value of init_round? And what does the return value 0 represent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value is how many results where locked and it's 0 if there is no previous round to lock
|
|
||
| def open_and_lock_previous(current_user) | ||
| init_round | ||
| return 0 if number == 1 || linked_round.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you returning early in case of a linked round? The linked round's individual rounds would all need to be locked, and returning early feels a bit premature...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is about locking the previous round as the title suggests. Linked Rounds do not have previous rounds
app/models/round.rb
Outdated
|
|
||
| result.mark_as_quit(current_user) | ||
|
|
||
| return 1 if number == 1 || linked_round.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this return value represent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how many results have been marked as quit
I think this is a good comprise between a full table for locks and quits?